/*
 * @lc app=leetcode.cn id=LCR 125 lang=cpp
 * @lcpr version=30204
 *
 * [LCR 125] 图书整理 II
 */

// @lcpr-template-start
using namespace std;
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// @lcpr-template-end
// @lc code=start
class CQueue
{
public:
    stack<int> A, B;
    CQueue()
    {
    }
    void appendTail(int value)
    {
        A.push(value);
    }
    
    int deleteHead()
    {
        if (!B.empty())
        {
            int tmp = B.top();
            B.pop();
            return tmp;
        }
        if (A.empty())
            return -1;
        while (!A.empty())
        {
            int tmp = A.top();
            A.pop();
            B.push(tmp);
        }
        int tmp = B.top();
        B.pop();
        return tmp;
    }
};

/**
 * Your CQueue object will be instantiated and called as such:
 * CQueue* obj = new CQueue();
 * obj->appendTail(value);
 * int param_2 = obj->deleteHead();
 */
// @lc code=end

/*
// @lcpr case=start
// ["BookQueue", "push", "push", "pop"][[], [1], [2], []]\n
// @lcpr case=end

 */
